package com.tang.managementdemo.controller;

import com.tang.managementdemo.pojo.Employ;
import com.tang.managementdemo.pojo.LoginInfo;
import com.tang.managementdemo.pojo.Result;
import com.tang.managementdemo.service.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping("/login")
    public Result login(@RequestBody Employ employ) {
        log.info("用户名：{}，密码：{}", employ.getUsername(), employ.getPassword());
        LoginInfo loginInfo = loginService.login(employ.getUsername(), employ.getPassword());
        return Result.success(loginInfo);
    }
}
